﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ECSE6770.Controllers
{
    [Authorize]
    public class StatsController : BaseController
    {
        [HttpPost]
        public ActionResult VideoEvent(int id, string name)
        {
            var vid = Db.Videos.First(v => v.Id == id);
            var u = ContextManager.LoadUserInterop(User.Identity.Name);
            var vidEvent = new VideoEvent
            {
                DatePosted = DateTime.Now,
                EventName = name,
                User = u,
                Video = vid
            };

            Db.VideoEvents.Add(vidEvent);
            Db.SaveChanges();

            return new EmptyResult();
        }
    }
}
